﻿using Xtee.Gen.XteeGen.XteeGenConfiguraton.Interfaces;

namespace Xtee.Gen.XteeGen.XteeGenConfiguraton.Serializers {


    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name = "XteeGenConfiguraton", Namespace = "http://XteeGen/XteeGenConfiguraton.xsd", Target = typeof(Xtee.Gen.XteeGen.XteeGenConfiguraton.Entities.XteeGenConfiguraton))]
    public class XteeGenConfiguratonSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXteeGenConfiguraton clazz;
        
        public XteeGenConfiguratonSerializer(IXteeGenConfiguraton clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            string element = string.Empty;
            try {
                element = "Name";
                Writer.WriteStartElement("Name");
                if (clazz.Name!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Name))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Name");
                }
                Writer.WriteEndElement();
                element = "WsdlPath";
                Writer.WriteStartElement("WsdlPath");
                if (clazz.WsdlPath!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.WsdlPath))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : WsdlPath");
                }
                Writer.WriteEndElement();
                element = "ModelOutputFolder";
                Writer.WriteStartElement("ModelOutputFolder");
                if (clazz.ModelOutputFolder!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ModelOutputFolder))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ModelOutputFolder");
                }
                Writer.WriteEndElement();
                element = "ImplOutputFolder";
                Writer.WriteStartElement("ImplOutputFolder");
                if (clazz.ImplOutputFolder!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ImplOutputFolder))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ImplOutputFolder");
                }
                Writer.WriteEndElement();
                element = "GenerateOperationsNamely";
                Writer.WriteStartElement("GenerateOperationsNamely");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.GenerateOperationsNamely))).ToString());
                Writer.WriteEndElement();
            }
            catch (System.Exception ex) {
                throw new global::Xtee.Core.Exceptions.PropertyWriteException(element, this.GetType(), ex);
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            string element = string.Empty;
            try {
                element = ">>XteeGenConfiguraton>Name";
                if (Reader.LocalName=="Name") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>XteeGenConfiguraton>Name");
                    }
                    clazz.Name = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Name")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>XteeGenConfiguraton>Name", Reader.LocalName);
                }
                element = ">>XteeGenConfiguraton>WsdlPath";
                if (Reader.LocalName=="WsdlPath") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>XteeGenConfiguraton>WsdlPath");
                    }
                    clazz.WsdlPath = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("WsdlPath")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>XteeGenConfiguraton>WsdlPath", Reader.LocalName);
                }
                element = ">>XteeGenConfiguraton>ModelOutputFolder";
                if (Reader.LocalName=="ModelOutputFolder") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>XteeGenConfiguraton>ModelOutputFolder");
                    }
                    clazz.ModelOutputFolder = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ModelOutputFolder")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>XteeGenConfiguraton>ModelOutputFolder", Reader.LocalName);
                }
                element = ">>XteeGenConfiguraton>ImplOutputFolder";
                if (Reader.LocalName=="ImplOutputFolder") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>XteeGenConfiguraton>ImplOutputFolder");
                    }
                    clazz.ImplOutputFolder = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ImplOutputFolder")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>XteeGenConfiguraton>ImplOutputFolder", Reader.LocalName);
                }
                element = ">>XteeGenConfiguraton>GenerateOperationsNamely";
                if (Reader.LocalName=="GenerateOperationsNamely") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>XteeGenConfiguraton>GenerateOperationsNamely");
                    }
                    clazz.GenerateOperationsNamely = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("GenerateOperationsNamely")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>XteeGenConfiguraton>GenerateOperationsNamely", Reader.LocalName);
                }
            }
            catch (System.Exception ex) {
                throw new global::Xtee.Core.Exceptions.PropertyAssignementException(element, this.GetType(), ex);
            }
        }
    }
}
